﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CoolERP_Entities;
using CoolERP_DAL;

namespace CoolERP_BLL
{
    public class ZL_GYSBLL : BaseBLL<ZL_GYS>
    {       
        public ZL_GYSBLL() { }
        public List<ZL_GYS> GetGYS(Dictionary<string, string> dc, string orderExpr, int? pageIndex, int pageSize, out int totalCount)
        {
            var predicate = PredicateExtensions.True<ZL_GYS>();
            if (dc.Count > 0)
            {
                if (dc.ContainsKey("BH") && !string.IsNullOrEmpty(dc["BH"]))
                    predicate = predicate.AndEx(t => t.BH.Contains(dc["BH"]));
                if (dc.ContainsKey("MC") && !string.IsNullOrEmpty(dc["MC"]))
                    predicate = predicate.AndEx(t => t.MC.Contains(dc["MC"]));
                if (dc.ContainsKey("Province") && !string.IsNullOrEmpty(dc["Province"]))
                {
                    int keyVal = Convert.ToInt32(dc["Province"]);
                    predicate = predicate.AndEx(t => t.ShengID == keyVal);
                }
                if (dc.ContainsKey("City") && !string.IsNullOrEmpty(dc["City"]))
                {
                    int keyVal = Convert.ToInt32(dc["City"]);
                    predicate = predicate.AndEx(t => t.ShiID == keyVal);
                }
            }
            IZL_GYSDAL _dal = new ZL_GYSDAL(context);
            return _dal.GetGYS(predicate.Compile(), orderExpr, pageIndex, pageSize, out totalCount);
        }
    }
}
